<?php
//
//  VictoryCMS - Content managment system and framework.
//  Copyright (C) 2009  Lewis Gunsch
//
//  This file is part of VictoryCMS.
//  
//  VictoryCMS is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  VictoryCMS is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with VictoryCMS.  If not, see <http://www.gnu.org/licenses/>.

/**
 * VictoryCMS - Component abstract class
 * 
 * @license http://www.gnu.org/licenses/gpl.html
 * @author Lewis Gunsch
 * @filesource
 * @package Components
 */

/**
 * @package Components
 * 
 * @todo Needs documentation finished
 * 
 */
abstract class Component {

	/** The name of the component. */
	protected $name;
	
	/** The current title of the particular component instance. */
	protected $title;
	
	/** Instance id of the component. */
	protected $id;
	
	/**
	 * Create a new component instance with instance id $id.
	 * 
	 * @param the instance id number.
	 **/
	abstract public function __construct( $id );
	
	/**
	 * Destroy a component instance, but does not remove
	 * it from the database.
	 */
	abstract public function __destruct();
	
	/**
	 * Returns the name of the component.
	 * 
	 * @return the component name string.
	 */
	abstract public function getName();
	
	/**
	 * This is called by the ComponentManager before the page
	 * is rendered.
	 */
	abstract public function componentPreProcess();
	
	/**
	 * Sets the current page path the component will be rendered on.
	 *
	 * @param String The current page path
	 */
	abstract public function setCurrentPage($currentPage);
	
	/**
	 * Returns the html of the component. If the users permission
	 * level is not high enough to view this component it will 
	 * not be rendered, or may be selectively rendered.
	 * 
	 * @return String the html string of the component.
	 */
	abstract public function renderComponent();
	
	/**
	 * The current title of the component
	 */
	public function getTitle() {
		return $this->title;
	}
	
	/**
	 * Returns the current instance id of the component.
	 * 
	 * @return The current id of the component.
	 */
	public function getId() {
		return $this->id;
	}
	
	/**
	 * Set the current title of the component.
	 * 
	 * @param the new title of the compon
	 */
	public function setTitle($newTitle) {
		$this->title = $newTitle;
	}	
}
?>
